package com.sky.controller.user;

import com.sky.result.Result;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ShopController
 *
 * @author liliudong
 * @version 1.0
 * @description 店铺控制器
 * @date 2023/6/25 11:34
 */
@RestController("userShopController")
@RequestMapping("/user/shop")
@Slf4j
@RequiredArgsConstructor
public class ShopController {

    private final RedisTemplate<String, Object> redisTemplate;

    private final static String CACHE_KEY = "shop.status";

    /**
     * 获取店铺营业状态
     *
     * @return
     */
    @GetMapping("/status")
    public Result<Integer> status() {
        Integer status = (Integer) redisTemplate.opsForValue().get(CACHE_KEY);
        return Result.success(status == null ? 0 : status);
    }
}
